<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page isELIgnored="false" %>
<%@ taglib uri="/permission" prefix="pe" %>
<jsp:include page="../../include/top.jsp"/>
<div class="main_body">
    <div class="span9 page_message">
        <section id="contents">
            <ul class="tab-nav nav">
                <li class="current"><a href="">用户组列表<span class="arrow fa fa-sort-up"></span></a></li>
                <li><a href="javascript:toAdd()">用户组添加/修改<span class="arrow fa fa-sort-up"></span></a>
                </li>
            </ul>
            <p class="normal_tips" style="display:none"><b class="fa fa-info-circle"></b></p>

            <form id="myForm" name="myForm" action="${BasePath}/group/list" method="post">
                <input type="hidden" name="start" id="start" value="${start }"/>
                <input type="hidden" name="limit" id="limit" value="${limit }"/>
                <input type="hidden" name="type" id="type" value="${type }"/>
                <input type="hidden" name="itemId" id="itemId" value="${itemId }"/>
            </form>
            <%--<div class="table-bar">--%>
                <%--<div class="fl">--%>
                    <%--<div class="tools">--%>
                        <%--<pe:permission key="add">--%>
                            <%--<a class="btn btn-success"--%>
                               <%--href="${BasePath}/base/group/toAdd?${PublicParams}">新增--%>
                            <%--</a>--%>
                        <%--</pe:permission>--%>
                    <%--</div>--%>
                <%--</div>--%>
            <%--</div>--%>
            <!-- 数据列表 -->
            <div class="data-table">
                <div class="table-striped">
                    <table cellspacing="1">
                        <!-- 表头 -->
                        <thead>
                        <tr>
                            <th class="row-selected row-selected">
                                <input type="checkbox" id="checkAll" class="check-all regular-checkbox"><label for="checkAll"></label>
                            </th>
                            <th>ID</th>
                            <th>组名</th>
                            <th>操作</th>
                        </tr>
                        </thead>
                        <tbody>
                        <c:forEach items="${groupList}" var="group">
                            <tr>
                                <td><input type="checkbox" id="check_${group.id}" name="ids[]" value="${group.id}" class="ids regular-checkbox"><label for="check_${group.id}"></label></td>
                                <td class="groupId">${group.id}</td>
                                <td>${group.name}</td>
                                <td>
                                    <pe:permission key="update">
                                        <a class=""
                                           href="${BasePath}/base/group/toModify?groupId=${group.id}&${PublicParams}">修改</a>
                                    </pe:permission>
                                    <pe:permission key="delete">
                                        <a class="confirm ajax-get" href="${BasePath}/base/group/del?groupId=${group.id}&${PublicParams}" redirect-url="${BasePath}/base/group/list?${PublicParams}">删除</a>
                                    </pe:permission>
                                    <pe:permission key="grant">
                                        <a class="" href="${BasePath}/base/group/toPermission?groupId=${group.id}&${PublicParams}">权限</a>
                                    </pe:permission>
                                </td>
                            </tr>
                        </c:forEach>
                        </tbody>
                    </table>
                </div>
            </div>
            <div class="page" id="pager"></div>
            <script type="text/javascript">
                var sign = 0;
                window.onload = function () {
                    PAGER.initPager('${start}', ' ${total}', '${limit}', 8, 'pager', getData);
                }
                function getData(currentPage, pageSize) {
                    if (sign > 0) {
                        $("#start").val(currentPage);
                        $("#limit").val(pageSize);
                        $("#myForm").submit();
                    }
                    sign = 1;
                }
            </script>
        </section>
    </div>
</div>
<script>
    function toAdd() {
        var idArray = new Array();
        $("input[name='ids[]']:checked").each(function () {
            var txt = $(this).val();
            idArray.push(txt);
        });
        //新增
        if (idArray.length == 0) {
            window.location.href = " ${BasePath}/base/group/toAdd?${PublicParams}";
        } else if (idArray.length == 1) {
            window.location.href = " ${BasePath}/base/group/toAdd?${PublicParams}&id=" + idArray;
        } else {
            layer.msg('请选择一条记录进行操作！', {icon: 5});
            return false;
        }
    }
</script>
<jsp:include page="../../include/bottom.jsp"/>
